<%@ page language="java" contentType= "text/html" pageEncoding="UTF-8"%>
<%@include file="/include/common/griduihead1.jsp"%>
<%@include file="/include/common/griduihead2.jsp"%>
<%
	page1.getPageTitle().setTitle("实体维护");
	
%>
<jm:form>
	<jm:layout postion="north">
		<jm:toolbar saveDisabled="false" deleteDisabled="false" exportDisabled="true" printDisabled="true"/>
		<jm:pageTitle />
		<jm:sp id="sp1" data="<%=Utils.TAG_FORM%>" tabSize="1">
		    <jm:tab colModel="200px;200px;*">
		        <jm:select name="psysName" caption="系統名稱" dataSource="pan" sql="select distinct sysName from pan..pan_table" />
		        <jm:select name="pdatasource" caption="数据源" codeList="fs1;pan"/>
		        <input name="pdatabase" caption="数据库" type="text"/>
		        <input name="ptableName" caption="表名%" type="text"/>
		        <input name="prem" caption="表中文名%" type="text"/>
		    </jm:tab>
    	</jm:sp>
		<jm:error></jm:error>
	</jm:layout>

	<jm:layout postion="center">
		<jm:columnEditors>
			 <jm:columnEditor id="e_sysname" type="combobox">
		       	<jm:combobox name="e_sysname" dataSource="pan" single="true" sql="select distinct sysName from pan..pan_table order by sysName" />
		    </jm:columnEditor>
		    <jm:columnEditor id="e_datasource" type="select">
	    		<jm:select name="e_datasource" codeList="fs1;pan" emptySupported="false"/>
		    </jm:columnEditor>
		    <jm:columnEditor id="e_database" type="combobox">
		       	<jm:combobox name="e_database" single="true" jumpConfig="parentid:'e_datasource',paramsfun:paramsfun_database,dataSource:'pan',sql:'SELECT   name   FROM   master..sysdatabases where dbid > 7  ORDER   BY   name'" />
		    </jm:columnEditor>
		    <jm:columnEditor id="e_tableName" type="text">
		        <input name="e_tableName" type="text"/>
		    </jm:columnEditor>
		    <jm:columnEditor id="e_keyname" type="text">
		        <input name="e_keyname" type="text"/>
		    </jm:columnEditor>
		    <jm:columnEditor id="e_enabwf" type="select">
		        <jm:select name="e_enabwf" codeList="0|N;1|Y" emptySupported="false" />
		    </jm:columnEditor>
		    <jm:columnEditor id="e_rem" type="text">
		        <input name="e_rem" type="text"/>
		    </jm:columnEditor>
		    <jm:columnEditor id="e_srt" type="text">
		        <input name="e_srt" type="text"/>
		    </jm:columnEditor>
		</jm:columnEditors>
		<jm:table id="grid1" dataSet="<%=ret.getSerchResult()%>" toolbar="true" loopFisrt="true" addRowConfig="reset:grid_reset" jump="true">
		    <jm:thead>
		        <tr>
		        	<td width="50px">序号</td>
					<td width="130px">&nbsp;</td>
		            <td config="cid:'tableName',editor:'text',editorid:'e_tableName'" width="100px">表名</td>
		            <td config="cid:'rem',editor:'text',editorid:'e_rem',width:100" width="120px">表[中文名]</td>
		            <td config="cid:'keyname',editor:'text',editorid:'e_keyname',width:48" width="50px">主鍵名</td>
		            <td config="cid:'enabwf',editor:'select',editorid:'e_enabwf'" width="70px">启用流程</td>
		            <td config="cid:'datasource',editor:'select',editorid:'e_datasource',removevent:false" width="100px">数据源</td>
		            <td config="cid:'database',editor:'combobox',editorid:'e_database'" width="100px">数据库</td>
		            <td config="cid:'sysname',editor:'combobox',editorid:'e_sysname'" width="100px">系統名稱</td>
		            <td config="cid:'srt',editor:'text',editorid:'e_srt',width:100" width="*">排序</td> 
		        </tr>
		    </jm:thead>
		    <jm:tbody>
		        <jm:tr>
		            <jm:td><input type="checkbox" name="key" value="<%=ret.grsv("sn")%>" /> <span id="rownumber"><%=ret.getTableRowIndex()+1%></span></jm:td>				
					<jm:td cid="col1">
						<a href="#" onclick="$P.openwin('page028.jsp?ptablesn=<%=ret.grsv("sn")%>', 'colwin', '', '', 0, 0);">
							<%=ret.grsv("rem").substring(0, ret.grsv("rem").length() > 10 ? 10 : ret.grsv("rem").length())%>
						</a>
						<input type="hidden" name="sn" value="<%=ret.grsv("sn")%>" />
					</jm:td>
		            <jm:td cid="tableName"></jm:td>
		             <jm:td cid="rem"></jm:td>
		            <jm:td cid="keyname"></jm:td>
		            <jm:td cid="enabwf"></jm:td>
		            <jm:td cid="datasource"></jm:td>
		            <jm:td cid="database"></jm:td>
		            <jm:td cid="sysname"></jm:td>
		            <jm:td cid="srt"></jm:td>
		        </jm:tr>
		    </jm:tbody>
		</jm:table> 		
	</jm:layout>

	<jm:layout postion="south"/>
</jm:form>
<jm:script><script type="text/javascript" charset="UTF-8">
	function onsave(actionvalue,p){
		var records = $('table[id=grid1] tbody tr[dirty=true]').getRecords();
		$P.form.appendRecords(records);
		submitForm(p);
	}
	
	function grid_reset(tr){
		tr.find('input[name=key]').remove();
		tr.find('input[name=sn]').val('');
		tr.find('span[id=rownumber],td[cid=rem],td[cid=tableName],td[cid=col1]').html('&nbsp;').attr('value',"");
		tr.find('td[cid=srt]').html($('table[id=grid1] td[cid=srt]').length+1);
		tr.find('td').attr('rowindex',$('table[id=grid1] td[cid=srt]').length);
	}
	
	function paramsfun_database(p){
		p['datasource'] = p['parentvalue'];
	}
</script></jm:script>
<%@include file="/include/common/griduiend.jsp"%>
